import { defineStore } from 'pinia'
import { getUserInfor } from '@/api/userinfo.js'

export const useUserStore = defineStore('useUser', {
  state: () => {
    return {
      imageUrl: '',
      identity: '',
      department: '',
      name: '',
      sex: '',
      account: '',
      email: '',
      companyname: '',
    }
  },
  persist: true,
  actions: {
    async userInfo(id) {
      const res = await getUserInfor(id)
      // console.log(res[0].image_url)
      this.imageUrl = res[0].image_url
      this.identity = res[0].identity
      this.department = res[0].department
      this.name = res[0].name
      this.sex = res[0].sex
      this.account = res[0].account
      this.email = res[0].email
    },

  },
  // persist: {
  //   //存储全部数据
  //   enabled: true,
  //   //关键字
  //   key: 'useUser',
  //   //存储位置
  //   storage: localStorage,
  // },
})
